package Thread;

class MyRunnable implements Runnable {
    public void run() {
        while (true) {
            System.out.println("Hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
    Runnable r = new MyRunnable();
    Thread t = new Thread(r);
    t.start();
    while(true) {
        System.out.println("Hello main");
        Thread.sleep(1000);
    }
    }
}
